<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>修改作品 - 系统后台 - {$Config.sitename}</title>
    <link rel="stylesheet" href="__CSS__/admin_inc.css" type="text/css">
    <link rel="stylesheet" href="__JS__/artDialog/skins/default.css" type="text/css">
    <link rel="stylesheet" href="__CSS__/yf.css" />
    <script type="text/javascript">
        //全局变量
        var GV = {
            DIMAUB: "__ROOT__/",
            JS_ROOT: "__JS__/"
        };
    </script>
    <script src="__JS__/wind.js"></script>
    <script src="__JS__/jquery.min.js"></script>
    <script type="text/javascript">
        var cateid = "{$cateid}";
    </script>
    <style type="text/css">
        .col-auto {
            overflow: hidden;
            _zoom: 1;
            _float: left;
            border: 1px solid #c2d1d8;
        }
        .col-right {
            float: right;
            width: 48%;
            overflow: hidden;
            margin-left: 6px;
            border: 1px solid #c2d1d8;
        }

        body fieldset {
            border: 1px solid #D8D8D8;
            padding: 10px;
            background-color: #FFF;
        }
        body fieldset legend {
            background-color: #F9F9F9;
            border: 1px solid #D8D8D8;
            font-weight: 700;
            padding: 3px 8px;
        }
        .list-dot{ padding-bottom:10px}
        .list-dot li,.list-dot-othors li{padding:5px 0; border-bottom:1px dotted #c6dde0; font-family:"宋体"; color:#bbb; position:relative;_height:22px}
        .list-dot li span,.list-dot-othors li span{color:#004499}
        .list-dot li a.close span,.list-dot-othors li a.close span{display:none}
        .list-dot li a.close,.list-dot-othors li a.close{ background: url("__IMAGES__/cross.png") no-repeat left 3px; display:block; width:16px; height:16px;position: absolute;outline:none;right:5px; bottom:5px}
        .list-dot li a.close:hover,.list-dot-othors li a.close:hover{background-position: left -46px}
        .list-dot-othors li{float:left;width:24%;overflow:hidden;}

        .attr{
            margin: 0px;
            padding: 10px;
            background: bisque;
            border: 1px dotted coral;
        }
        .attr ul{
            display: block;
        }
        .attr ul li{
            margin-top: 5px;
        }
        td.ship input,
        td.ship select{
            margin-bottom: 5px;
        }

        td#mt input{
            margin-top: 3px;
            width: 40%;
        }

        input[type=radio]{
            margin-bottom: 6px;
            border-radius: 8px;
        }
        .opt em{
            display: inline-block;
            margin-left: 10px;
            width: 100px;
            text-align: center;
            height: 80px;
            line-height: 80px;
            font-size: 20px;
            border: 1px solid #c1c1c1;
            background: #f0ead8;
            overflow: hidden;
            cursor: pointer;
        }
        .opt a{
            display: inline-block;
            margin-bottom: 30px;
            overflow: hidden;
        }


    </style>
</head>
<body class="J_scroll_fixed">
<div class="wrap J_check_wrap">
    <form name="myform" id="myform" action="{:U('Works/edit')}" method="post" class="J_ajaxForm" enctype="multipart/form-data">
        <div class="col-right">
            <div class="table_full">
                <table width="100%">
                    <tr>
                        <td><b>作品主图</b></td>
                    </tr>
                    <tr>
                        <td>
                        	<div style="text-align: center;">
	                        	<!-- <Form function="mainimage" parameter="image,image,$data['image'],works"/>-->
	                        	<foreach name="data.all_pic" item="pic">
	                        	<div class="yf_box">
	                        		<Form function="yf_image_two" parameter="$key+1,image,image,$pic['thumb'],$pic['pic'],works"/><span class="gray"> 双击可以查看图片！</span>
	                        		<div class="yf_clear"></div>
	                        	</div>
	                        	</foreach>
	                        </div>
                        </td>
                    </tr>
                    <tr>
                        <td><input type="button" value="+添加用料" class="btn" name="addmt" />如果需删除请先保存已修改的信息</td>
                    </tr>
                    <tr>
                        <td id="mt">
                            <foreach name="data.works_materials" item="vo">
                                <span>
                                    <input type="text" class="input" name="mname[]" value="{$vo.mname}" placeholder="用料名称">
                                    <input type="text" class="input" name="mvalue[]" value="{$vo.mvalue}" placeholder="用量">
                                    <input type="hidden" name="materials_id[]" value="{$vo.id}" />
                                    <a class="J_ajax_del" data-msg="确定删除吗?" href="{:U('Works/delmaterials',array('mtid'=>$vo['id']))}">删除</a>
                                </span>
                            </foreach>

                        </td>
                    </tr>

                    <tr>
                        <td><input type="button" value="+添加做法" class="btn" name="addopt" /></td>
                    </tr>
                    <tr>
                        <td id="opt">
                            <foreach name="data.works_makestep" item="v">
                                <div class="opt" style="width: 510px;">
                                    <input type="hidden" name="stepid[]" value="{$v.id}"/>
                                    <textarea cols="60%" rows="10" name="scontent[]">{$v.scontent}</textarea>
                                        <span class="yf_opt_one">
                                        	<!-- <Form function="hbqImages" parameter="simage[],bluk,$v['simage'],works" />-->
                                        	<Form function="yf_image_pr" parameter="simage[],bluk,$v['simage'],works"/>
                                        <!-- <div class="upimg-show">
                                        		<img src="{$v.simage}" width="80" height="80">
                                        		<i class="delimg">删除</i>
                                        	</div>-->
                                        </span>
                                    <span class="delbtn"><a class="delopt" data-id="{$v.id}" href="javascript:void(0)">删除</a></span>
                                </div>
                            </foreach>


                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="col-auto">
            <div class="h_a">信息发布</div>
            <div class="table_full">
                <table width="100%">
                    <tr>
                        <th width="80">栏目<span class="require_red">*</span></th>
                        <td><select name="cateid">{$category}</select></td>
                    </tr>
                    <tr>
                        <th width="80">名称<span class="require_red">*</span></th>
                        <td><input type="text" style="width:320px;" name="title" id="title" class="input input_hd J_title_color" value="{$data.title}" onkeyup="strlen_verify(this, 'title_len', 30)" />
                            <span>还可输入<B><span id="title_len">30</span></B> 个字符</span> <span></span></td>
                    </tr>
                    <tr>
                        <th width="80">内容</th>
                        <td><textarea name="content" id="" cols="90%" rows="15">{$data.content}</textarea></td>
                    </tr>
                    <tr>
                        <th width="80">小贴士</th>
                        <td><textarea name="note" id="" cols="90%" rows="10">{$data.note}</textarea></td>
                    </tr>
                    <tr>
                        <th width="80">状态</th>
                        <td>
                    <span class="switch_list cc">
                    <label><input type="radio" name="status" value="1" <eq name="data.status" value="1">checked</eq>> <span>审核</span></label>
                    <label><input type="radio" name="status" value="0" <eq name="data.status" value="0">checked</eq>><span>待审核</span></label>
                 </span>
                        </td>
                    </tr>
                    <tr>
                        <th width="80">推荐</th>
                        <td>
                    <span class="switch_list cc">
                    <label><input type="radio" name="iftj" value="1" <eq name="data.iftj" value="1">checked</eq> ><span>推荐</span></label>
                    <label><input type="radio" name="iftj" value="0" <eq name="data.iftj" value="0">checked</eq>><span>不推荐</span></label>
                 </span>
                        </td>
                    </tr>
                    <tr>
                        <th width="80">推荐首页</th>
                        <td>
                    <span class="switch_list cc">
                    <label><input type="radio" name="ifindex" value="1" <eq name="data.ifindex" value="1">checked</eq>><span>推荐</span></label>
                    <label><input type="radio" name="ifindex" value="0" <eq name="data.ifindex" value="0">checked</eq>><span>不推荐</span></label>
                 </span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="btn_wrap" style="z-index:999;text-align: center;">
            <div class="btn_wrap_pd">
                <input type="hidden" name="workid" value="{$data.workid}"/>
                <button class="btn btn_submit J_ajax_submit_btn"type="submit">提交</button>
                <button class="btn btn_close J_ajax_close_btn" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="__JS__/common.js"></script>
<script type="text/javascript" src="__JS__/content_addtop.js"></script>
<script type="text/javascript" src="__JS__/yf_upload/jquery.ui.widget.js"></script>
<script type="text/javascript" src="__JS__/yf_upload/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="__JS__/yf_upload/jquery.fileupload.js"></script>
<script type="text/javascript">
    $(function () {
        $(".J_ajax_close_btn").on('click', function (e) {
            e.preventDefault();
            Wind.use("artDialog", function () {
                art.dialog({
                    id: "question",
                    icon: "question",
                    fixed: true,
                    lock: true,
                    background: "#CCCCCC",
                    opacity: 0,
                    content: "您确定需要关闭当前页面嘛？",
                    ok:function(){
                        setCookie("refersh_time",1);
                        window.close();
                        return true;
                    }
                });
            });
        });

        /**
         * 选择意向判断个数
         */
        $("input[name='mindid']").on('click',function(){
            var num=$("input[name=mindid]:checked").length;
            if(num>3){
                alert('最多只能勾选三个交换意向');
                return false;
            }
        })

        /*添加用料*/
        $("input[name='addmt']").on('click', function (){
            var arr="<span>"
            arr+="<input type='text' class='input' name='mname[]' placeholder='用料名称'/>";
            arr+="<input type='text' class='input' name='mvalue[]' placeholder='用量'/> <a class='delmt' href='javascript:void(0)'>删除</a>";
            arr+="</span>";
            $("#mt").append(arr);

            $(".delmt").on("click",function(){
                $(this).parent('span').remove();
                return false;
            })
        });
        /**
         * 添加操作步骤
         */
        $('input[name="addopt"]').on('click', function (){
            var arr="<div class='opt'>"
            arr+="<textarea cols='40%' rows='10' name='scontent[]'></textarea>";
            arr+="<span class='yf_opt_one'><Form function='yf_image_pr' parameter='simage[],bluk, ,works'/></span>";
            arr+="<span class='delbtn'><a class='delopt' href='javascript:void(0)'>删除</a></span>";
            arr+="</div>";
            $("#opt").append(arr);
			yf_start();
            $(".delopt").on("click",function(){
                $(this).parent().parent('div').remove();
                return false;
            })
        });

        $(".delmt").on("click",function(){
            $(this).parent('span').remove();
            return false;
        });

        $(".delopt").on("click",function(){
            $(this).parent().parent('div').remove();
            return false;
        });

        $(".delimg").on("click",function(){
            $(this).parent().parent().find('input[type=button]').show();
            $(this).parent().parent().find('input[type=hidden]').val('');
            $(this).parent().remove();
        });

        function yf_start()
		{
			$('.yf-fileupload-good').fileupload({
	 	    	dataType: 'json',
	 	        add: function (e, data) {
	 	 	        $(this).parent().parent().find('img').attr('src', '/static/images/load2.gif');
	 	            data.submit();
	 	        },
	 	        done: function (e, data) {
	 	        	var info = data.result.content;
	 	        	console.log(data);
		 	        if(data.result.error == 0)
		 	        {
			 	        var path = info.path + "yf_" + info.savename;
					 	$(this).parent().find('img').attr('src', path);
						$(this).parent().find('.yf-img-value').val(path);
		 	        }
		 	        else
		 	        {
		 	        	$.tipMessage(info, 2, 3000);
				 	    $(this).parent().find('img').attr('src', '/static/images/icon/yf_upload2.png');
		 	        }
	 	        }
	 	    });
		}
		yf_start();

    });

</script>
<script type="text/javascript" src="__JS__/kindeditor.js"></script>
<script>
KindEditor.ready(function(K) {
	var YF = {
			siteUrl: "__ROOT__/",
			};
	$("input[class^='hy-uploadimg']").each(function(i, v) {
		var _this = this;
		var index = i;
		var args =$('.yf-pic-'+(index+1)).attr('data-args') ? '&args=' + $('.yf-pic-'+(index+1)).attr('data-args') : '';
		var setting = '&module=' + $('.yf-pic-'+(index+1)).attr('data-mod') + '&authkey=' + $('.yf-pic-'+(index+1)).attr('data-authkey');
		var upload_url = YF.siteUrl + 'index.php?a=yf_sign&c=Files&m=Upload&num='+ index + args + setting;
		
		var _callback = function(data) {
			    if(data.error == 0)
			    {
			    	var img_path = data.content.path + "yf_" + data.content.savename;
			    	var pic_path = data.content.path + data.content.savename;
				    $('.yf-pic-'+data.num).val(img_path);
				   // $('#yf-image-'+data.num).attr('src', "../."+img_path);
				    $('.yf-pic-'+data.num).attr('data-pic', pic_path);
			    }
			    else
			    {
			    	alert(data.content);
			    }
			}
		var uploadbutton = K.uploadbutton({
			button: _this,
			fieldName: 'file_name'+index,
			url: upload_url,
			afterUpload: _callback,
			afterError: function(str) {
				alert('自定义错误信息: ' + str);
			}
		});
		uploadbutton.fileBox.change(function(e) {
			uploadbutton.submit();
		});
	}); //each
});
</script>
</body>
</html>